<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="css/skin.css" />
    <script type="text/javascript">
        function logout() {
            if(window.confirm('您确定要退出吗？')) {
                top.location = 'login';
            }
        }
        function insert() {
            window.location.href="/papermanage/chaxun";
        }
    </script>
</head>
<body>
<div width="1000px" id="top" th:include="/top :: top"></div>
<div id="lief" th:include="/lief :: lief"></div>
<div id="chaxun">
    <input type="button" onclick="insert()" value="添加论文">
    <table width="800px">
        <tr>
            <td colspan="2">
                <form action="" method="">
                    <table id="chaxu" width="100%"  class="cont tr_color">

                    </table>
                </form>
            </td>
        </tr>
    </table>
</div>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $(function (){
        fenye(1);
    })

    function fenye(page) {
        $.ajax({
            "url":"/papermanage/tpaper/seltps",
            "type":"get",
            "data":{"page":page},
            "dataType":"json",
            "success":function(a){
                $('#chaxu').html("");
                var paper = a.result["posts"]
                var html = "";
                html+="<tr>\n" +
                    "<th>论文主题</th>\n" +
                    "<th>作者</th>\n" +
                    "<th>论文类型</th>\n" +
                    "<th>发表时间</th>\n" +
                    "<th>修改时间</th>\n" +
                    "<th>操作</th>\n" +
                    "</tr>";
                for(var i = 0 ; i < paper.length ; i++){
                    html+="<tr align=\"center\" class=\"d\">\n" +
                        "<td><input type=\"checkbox\" value=\"\" /></td>\n" +
                        "<td>"+paper[i].title+"</td>\n" +
                        "<td>"+paper[i].createdBy+"</td>\n" +
                        "<td>"+paper[i].typeCode+"</td>\n" +
                        "<td>"+paper[i].creationDate+"</td>\n" +
                        "<td>"+paper[i].modifyData+"</td>\n" +
                        "<td><a onclick='del("+paper[i].id+")'>删除</a></td>\n" +
                        "</tr>";
                }
                $('#chaxu').append(html);
                var html1 = "";
                html1+='<li><a onclick="fenye('+a.result["p"].firstPage+')">首页</a>';
                html1+='<a onclick="fenye('+a.result["p"].prePage+')">上一页</a>';
                html1+='<a onclick="fenye('+a.result["p"].nextPage+')">下一页</a>';
                html1+='<a onclick="fenye('+a.result["p"].lastPage+')">尾页</a></li>';
                $('#chaxu').append(html1);
            },
            "error":function(){
                alert("服务器错误");
            }
        })
    }

    function del(id) {
        $.ajax({
            "url":"/papermanage/tpaper/delTp",
            "type":"get",
            "data":{"id":id},
            "dataType":"json",
            "success":function(a){
                var r = parseInt(a.result["result"]);
                if(r>0){
                    alert("删除成功")
                }else {
                    alert("删除失败")
                }
            },
            "error":function(){
                alert("服务器错误");
            }
        })
    }
</script>
</html>